import React from "react";
import './style.less'
const city=['北京','天津',"上海","郑州","杭州","南京","邓州","重庆","广州","深圳","珠海","澳门","温州","洛阳","开封"]

const CityList=(props)=>{

    //定义一个函数，获取选中的当前城市
    function clickCityHandle(city){
       // console.log(city)
       // 利用props将city传到父组件中，调用onEvent的方法
       props.onEvent(city)
        window.history.back()
   }
    return(
        <div className="city-list-container">
            <h3>热门城市</h3>
          <ul className="clear-fix">
              {
                  city.map((item,index)=>{
                      return <li key={index} onClick={ ()=>clickCityHandle(item)}><span>{item}</span></li>
                  })
              }
          </ul>
        </div>
    )
}
export default CityList